<!DOCTYPE html>
<html lang="en">
<head>
    #include("../include/header.html")
</head>
<body>
<div id="tree" class="ztree" style="padding:15px 20px;"></div>
#include("../include/footer.html")
<script type="text/javascript">
    var jsonDataUrl = '${url}';
    var tree, setting = {
        view: {
            showLine: true,
            selectedMulti: false
        },
        data: {
            simpleData: {
                enable: true,
                idKey: "id",
                pIdKey: "parentId",
                rootPId: ""
            }
        },
        callback: {
            beforeClick: function (treeId, treeNode, clickFlag) {

            },
            onClick: function (event, treeId, treeNode) {
                // console.log(treeNode);
            }
        }
    };
    $(document).ready(function () {
        $.get(jsonDataUrl, function (zNodes) {
            // 初始化树结构
            tree = $.fn.zTree.init($("#tree"), setting, zNodes);

            // 默认展开一级节点
            var nodes = tree.getNodesByParam("level", 0);
            for (var i = 0; i < nodes.length; i++) {
                tree.expandNode(nodes[i], true, false, false);
            }

            tree.expandAll(tree);

            // //异步加载子节点（加载用户）
            // var nodesOne = tree.getNodesByParam("isParent", true);
            // for (var j = 0; j < nodesOne.length; j++) {
            //     tree.reAsyncChildNodes(nodesOne[j], "!refresh", true);
            // }
        });
    });
</script>
</body>
</html>